import { defineStore } from 'pinia'
import { ref } from 'vue'
import { loginApi } from '@/api/user'

const useUserStore = defineStore(
  'user',
  () => {
    const userinfo = ref({})

    const login = async (data: any) => {
      const { data: res } = await loginApi(data)
      userinfo.value = res.data
    }

    return {
      userinfo,
      login,
    }
  },
  {
    persist: true,
  },
)

export default useUserStore
